package com.huang.array;

/**
 * 目标：
 * 掌握动态初始化数组
 */
public class Demo5_Array {
    public static void main(String[] args) {
        int[] ages = new int[3];
        for (int i = 0; i < ages.length; i++) {
            System.out.println(ages[i]);
        }

        ages[0] = 1;
        ages[1] = 1;
        ages[2] = 1;

        for (int i = 0; i < ages.length; i++) {
            System.out.println(ages[i]);
        }

        //默认值
        //byte short int char long默认值为0
        byte[] arr = new byte[10];
        System.out.println(arr[0]);
        System.out.println(arr[9]);
        System.out.println("------------------");
        short[] arr1 = new short[10];
        System.out.println(arr1[0]);
        System.out.println(arr1[9]);
        System.out.println("-------------------");
        char[] arr2 = new char[10];
        System.out.println((int) arr2[0]);
        System.out.println((int) arr2[9]);
        System.out.println("------------------");
        long[] arr3 = new long[10];
        System.out.println(arr3[0]);
        System.out.println(arr3[9]);
        System.out.println("------------------");

        //float double类型的默认值为0.0
        float[] arr4 = new float[10];
        System.out.println(arr4[0]);
        System.out.println(arr4[9]);
        System.out.println("------------------");
        double[] arr5 = new double[10];
        System.out.println(arr5[0]);
        System.out.println(arr5[9]);
        System.out.println("------------------");
        //String类型为null
        String[] arr6 = new String[10];
        System.out.println(arr6[0]);
        System.out.println(arr6[9]);
        System.out.println("------------------");
    }
}